/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("Consumer",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VOL.Entity.DomainModels;
using VOL.Dongxing.IServices;
using Microsoft.AspNetCore.Authorization;
using VOL.Core.ObjectActionValidator;
using VOL.Entity.DomainModels.Dto;
using VOL.System.IRepositories;
using VOL.System.Repositories;
using VOL.Dongxing.IRepositories;
using VOL.Dongxing.Repositories;

namespace VOL.Dongxing.Controllers
{
    [Route("api/FrontConsumer")]
    public partial class ConsumerController
    {
        private readonly IConsumerService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public ConsumerController(
            IConsumerService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }


        [HttpPost, HttpGet, Route("login"), AllowAnonymous]
        //[ObjectModelValidatorFilter(ValidatorModel.Login)]
        public async Task<IActionResult> Login([FromBody] LoginConsumerInfo loginInfo)
        {
            return Json(await Service.Login(loginInfo));
        }




        [ApiExplorerSettings(IgnoreApi = false)]//显示出来
        public override ActionResult Del([FromBody] object[] keys)
        {

            IConsumerRepository repository = ConsumerRepository.Instance;
            repository.DeleteWithKeys(keys);
            return base.Del(keys);

        }

    }
}
